<?php 
 include_once dirname(__FILE__)."/config.php";
 class reunion_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_id;
		 protected $_code_ue;
		 protected $_date;
		 protected $_lieu;
		 protected $_concepteur;
		 protected $_enseignant;
		 protected $_objectif;
		 protected $_observation;
		 public function get_name_table(){ return "reunion";}
		 public function get_name_id(){ return "id";}
		 public function get_name_code_ue(){ return "code_ue";}
		 public function get_name_date(){ return "date";}
		 public function get_name_lieu(){ return "lieu";}
		 public function get_name_concepteur(){ return "concepteur";}
		 public function get_name_enseignant(){ return "enseignant";}
		 public function get_name_objectif(){ return "objectif";}
		 public function get_name_observation(){ return "observation";}
		 public function set_id($parametre){  $this->_id=$parametre;}	
		 public function set_code_ue($parametre){  $this->_code_ue=$parametre;}	
		 public function set_date($parametre){  $this->_date=$parametre;}	
		 public function set_lieu($parametre){  $this->_lieu=$parametre;}	
		 public function set_concepteur($parametre){  $this->_concepteur=$parametre;}	
		 public function set_enseignant($parametre){  $this->_enseignant=$parametre;}	
		 public function set_objectif($parametre){  $this->_objectif=$parametre;}	
		 public function set_observation($parametre){  $this->_observation=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id(){ return $this->_id;}
		 public function get_code_ue(){ return $this->_code_ue;}
		 public function get_date(){ return $this->_date;}
		 public function get_lieu(){ return $this->_lieu;}
		 public function get_concepteur(){ return $this->_concepteur;}
		 public function get_enseignant(){ return $this->_enseignant;}
		 public function get_objectif(){ return $this->_objectif;}
		 public function get_observation(){ return $this->_observation;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 reunion(
			code_ue,
			date,
			lieu,
			concepteur,
			enseignant,
			objectif,
			observation)
 VALUES(
			'".$this->_code_ue."',
			'".$this->_date."',
			'".$this->_lieu."',
			'".$this->_concepteur."',
			'".$this->_enseignant."',
			'".$this->_objectif."',
			'".$this->_observation."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_code_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_ue='".$this->_code_ue."'";
}
if(!empty($this->_date)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date='".$this->_date."'";
}
if(!empty($this->_lieu)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
lieu='".$this->_lieu."'";
}
if(!empty($this->_concepteur)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
concepteur='".$this->_concepteur."'";
}
if(!empty($this->_enseignant)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
enseignant='".$this->_enseignant."'";
}
if(!empty($this->_objectif)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
objectif='".$this->_objectif."'";
}
if(!empty($this->_observation)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
observation='".$this->_observation."'";
}
$sql="UPDATE 
reunion SET 
 ".$sql."
								WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
reunion 
 
									WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
reunion ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id,
		code_ue,
		date,
		lieu,
		concepteur,
		enseignant,
		objectif,
		observation
 FROM 
 reunion";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_id=$row->id;
		$this->_code_ue=$row->code_ue;
		$this->_date=$row->date;
		$this->_lieu=$row->lieu;
		$this->_concepteur=$row->concepteur;
		$this->_enseignant=$row->enseignant;
		$this->_objectif=$row->objectif;
		$this->_observation=$row->observation;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>